﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Starfire3d.Interfaces;
using Starfire3d.Data;

namespace Starfire3d.Data.Behaviours.Targeting
{
    public class TargetRandom : BaseBehaviour, ITargetingBehaviour
    {
        #region ITargetingBehaviour Members

        public Unit PickTarget(Unit entity)
        {
            Unit[] list = DataStore.GetAll<Unit>();
            int maxTargets = list.Length;
            Unit obj = null;

            while (true)
            {
                if (maxTargets < 2)
                    break;

                obj = list[RandomGenerator.Rand(maxTargets) - 1];
                if (obj.Entity_Name != entity.Entity_Name)
                    break;
            }

            return obj;
        }

        public int SelectRange(Unit entity)
        {
            if (entity.Sheet.Details.HasSensors())
                return entity.Sheet.Details.BestRange();
            else
                return 10;
        }

        #endregion
    }
}
